package cn.com.smartdevices.bracelet.chart.util;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.C2056y;
import com.goodving.guli.bt.model.PersonInfo;
import com.goodving.guli.bt.profile.scale.C3515h;
import com.goodving.guli.bt.utils.C0893f;
import com.goodving.guli.model.Keeper;
import com.goodving.guli.utility.Constants;

import java.text.DecimalFormat;

public final class ChartData {
    public static final String KEY_MODE = "Mode";
    public static final String KEY_SOURCE = "Source";
    public static final int MODE_STEP = 1;
    public static final int f4046a = 0;
    public static final int f4047b = 16;
    public static final int f4048c = 256;
    public static final int f4049d = 4096;
    public static final int f4050e = 0;
    public static final int f4051f = 1;
    public static final String f4052g = "From";
    public static final String f4053h = "Action";
    public static final String f4054i = "DynamicActivitySubTitle";
    public static final String f4055j = "Key";
    public static final String f4056k = "Weight_UserId";
    public static final String f4057l = "Weight_AdvData";
    public static final String f4058m = "DynamicView";
    public static final String f4059n = "RefCompleteGoal";
    private static PersonInfo f4060o;

    public static DynamicData m8731a() {
        return DynamicData.getInstance();
    }

    public static String m8732a(double d, int i) {
        String str = "####";
        if (i < 0) {
            throw new IllegalArgumentException("Accuracy must >= 0");
        }
        if (i > 0) {
            str = str + ".";
            int i2 = f4050e;
            while (i2 < i) {
                i2 += f4051f;
                str = str + "#";
            }
        }
        return new DecimalFormat(str).format(d);
    }

    public static String m8733a(long j) {
        return new DecimalFormat("#,###,###").format(j);
    }

    public static void m8734a(View view, int i, Context context) {
        TextView textView = (TextView) view.findViewById(R.id.item_value);
        TextView textView2 = (TextView) view.findViewById(R.id.item_value_1);
        TextView textView3 = (TextView) view.findViewById(R.id.item_value_unit);
        TextView textView4 = (TextView) view.findViewById(R.id.item_value_unit_1);
        String[] e = C0893f.m9095e(i);
        CharSequence string;
        if (e[f4050e].equals(Constants.VIA_RESULT_SUCCESS)) {
            string = context.getString(R.string.unit_min);
            textView.setVisibility(View.GONE);
            textView3.setVisibility(View.GONE);
            textView2.setText(e[f4051f]);
            textView4.setText(string);
            return;
        }
        string = context.getString(R.string.unit_hour);
        CharSequence string2 = context.getString(R.string.unit_min_short);
        textView.setVisibility(View.VISIBLE);
        textView3.setVisibility(View.VISIBLE);
        textView.setText(e[f4050e]);
        textView3.setText(string);
        textView2.setText(e[f4051f]);
        textView4.setText(string2);
    }

    public static void m8735a(View view, String str, String str2) {
        TextView textView = (TextView) view.findViewById(R.id.item_value_unit);
        ((TextView) view.findViewById(R.id.item_value)).setText(str);
        if (str2 != null) {
            textView.setText(str2);
        }
    }

    public static String[] m8736a(Context context, int i) {
        return m8737a(context, i, 2);
    }

    public static String[] m8737a(Context context, int i, int i2) {
        String[] strArr = new String[2];
        float f = (float) i;
        f4060o = Keeper.readPersonInfo();
        if (f4060o.getUnit() == f4051f) {
            return C2056y.m15948a(context, Float.valueOf(((float) i) * 1.0f), i2);
        }
        if (f4060o.getUnit() != 0) {
            return strArr;
        }
        if (i >= C3515h.f17660E) {
            strArr[f4050e] = m8732a((double) (f / 1000.0f), i2);
            strArr[f4051f] = context.getString(R.string.unit_kilometer);
            return strArr;
        }
        strArr[f4050e] = String.valueOf(i);
        strArr[f4051f] = context.getString(R.string.unit_meter);
        return strArr;
    }
}
